<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>计算器</title>
	</head>
	<body>
		<input type="number" id="number1"  /><br>
		<input type="number"  id="number2" /><br>
		<button type="button" onclick="Add();">+</button>
		<button type="button" onclick="Minus();">-</button>
		<button type="button" onclick="Multiply();">*</button>
		<button type="button" onclick="Divider();">/</button>
		
		结果等于：<span id="span1"></span>
	</body>
	<script type="text/javascript">
		 function Add(){
			number1 = parseInt(document.getElementById("number1").value);
			number2 = parseInt(document.getElementById("number2").value);
			var result = number1 + number2;
			document.getElementById("span1").innerHTML=result;
		 }
		 function Minus(){
			 number1 = parseInt(document.getElementById("number1").value);
			 number2 = parseInt(document.getElementById("number2").value);
			 var result = number1 - number2;
			 document.getElementById("span1").innerHTML=result;
		 }
		 function Multiply(){
			 number1 = parseInt(document.getElementById("number1").value);
			 number2 = parseInt(document.getElementById("number2").value);
			 var result = number1 * number2;
			 document.getElementById("span1").innerHTML=result;
		 }
		 function Divider(){
			 number1 = parseInt(document.getElementById("number1").value);
			 number2 = parseInt(document.getElementById("number2").value);
			 if(number2==0){
			 alert("除数不能为0");
			 }
			 var result = number1 / number2;
			 document.getElementById("span1").innerHTML=result;
		 }
	</script>
</html>
